﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DebitNoteView.aspx.cs" Inherits="Main_ServiceInvoice_DebitNoteView" Culture="en-GB" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxControl" %>
<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>
<%@ Register Src="~/User Controls/Pager.ascx" TagPrefix="custom" TagName="Pager" %>
<%@ Register Src="~/User Controls/CommonControls.ascx" TagName="CommonControls" TagPrefix="MyControls" %>
<%@ Register Assembly="CalendarExtenderPlus" Namespace="AjaxControlToolkitPlus" TagPrefix="advancedCalender" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Credit Note View</title>
    <link href="../../../Styles/accounts.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" language="javascript">
      function checkdate() {
          
           if (document.getElementById("txtfrom").value == '') {
                alert('Specify From date!');
                document.getElementById("txtfrom").focus();
                return false;
            }
            else if (document.getElementById("txtto").value == '') {
                alert('Specify To Date!');
                document.getElementById("txtto").focus();
                return false;
            }
            else {
                var strFromDate = document.getElementById("txtfrom").value;
                var strToDate = document.getElementById("txtto").value;
                var dtFrom = parseInt(strFromDate.substring(0, 2), 10);
                var monFrom = parseInt(strFromDate.substring(3, 5), 10);
                var yrFrom = parseInt(strFromDate.substring(6, 10), 10);
                var dtTo = parseInt(strToDate.substring(0, 2), 10);
                var monTo = parseInt(strToDate.substring(3, 5), 10);
                var yrTo = parseInt(strToDate.substring(6, 10), 10);
                var dateFrom = new Date(yrFrom, monFrom, dtFrom);
                var dateTo = new Date(yrTo, monTo, dtTo);
                if (dateTo < dateFrom) {
                    alert("from date cannot be greater than to date");
                    document.getElementById("txtfrom").focus();
                    return false;
                }
                else {
                    return true;
                }
            }            
        } 
           function EnabledTabKey(id, e) {
            var keycode;
            if (window.event) {
                keycode = window.event.keyCode;
            }
            else if (e) {
                keycode = e.which;
            }
            else {
                return true;
            }

            if (keycode == 9) {
                // if is the tab key                
                return true;
            }
            else {
                return false;
            }
        }
              
    </script>
</head>
<body >
    <form id="form1" runat="server">
    <asp:ScriptManager ID="scriptmanger1" runat="server">
    </asp:ScriptManager>
    <acc:heading ID="pagehead" runat="server" HeadingText="Debit Note View" />
    <div style="width: 90%; margin-left: 5%; margin-right: 5%">
        <asp:Label ID="lblMsg" runat="server"></asp:Label>
        <asp:Panel ID="pnlDate" runat="server" Width="100%">
            <table class="tablecontent" align="center" style="width:100%;">
                <tr>
                    <td align="right" style="padding-top:5px;">
                        From&nbsp;&nbsp;<asp:TextBox ID="txtFrom" CssClass="input" runat="server" onkeydown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                        <asp:ImageButton ID="btnDateFrom" runat="server" ImageUrl="~/Images/calendar.gif" />
                        <advancedCalender:CalendarExtenderPlus ID="calFromDate" runat="server" PopupButtonID="btnDateFrom" Format="dd/MM/yyyy" TargetControlID="txtFrom">
                    </advancedCalender:CalendarExtenderPlus>
                        <%--<AjaxControl:CalendarExtender ID="cal1" runat="server" PopupButtonID="btnDateFrom"
                            TargetControlID="txtFrom" Format="dd/MM/yyyy" Enabled="True">
                        </AjaxControl:CalendarExtender>
                        <AjaxControl:MaskedEditExtender ID="maskExt1" runat="server" MaskType="Date" Mask="99/99/9999"
                            TargetControlID="txtFrom" Enabled="True">                        </AjaxControl:MaskedEditExtender>
                        <AjaxControl:MaskedEditValidator ID="maskValid1" runat="server" ControlExtender="maskExt1"
                            InvalidValueMessage="Invalid Date !" Display="Dynamic" ValidationGroup="V" ControlToValidate="txtFrom"
                            ErrorMessage="maskValid"></AjaxControl:MaskedEditValidator>--%>
                    </td>
                    <td  style="padding-top:5px;">
                        &nbsp;&nbsp;&nbsp;To&nbsp;&nbsp;<asp:TextBox ID="txtTo" runat="server" CssClass="input" onkeydown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                        <asp:ImageButton ID="btnDateTo" runat="server" ImageUrl="~/Images/calendar.gif" />
                        <advancedCalender:CalendarExtenderPlus ID="calToDate" runat="server" PopupButtonID="btnDateTo" Format="dd/MM/yyyy" TargetControlID="txtTo">
                    </advancedCalender:CalendarExtenderPlus>
                      <%--<AjaxControl:CalendarExtender ID="cal2" runat="server" PopupButtonID="btnDateTo"
                            TargetControlID="txtTo" Format="dd/MM/yyyy" Enabled="True">
                        </AjaxControl:CalendarExtender>
                        <AjaxControl:MaskedEditExtender ID="maskExt2" runat="server" MaskType="Date" Mask="99/99/9999"
                            TargetControlID="txtTo" Enabled="True">
                        </AjaxControl:MaskedEditExtender>
                        <AjaxControl:MaskedEditValidator ID="maskValid2" runat="server" ControlExtender="maskExt2"
                            InvalidValueMessage="Invalid Date !" Display="Dynamic" ValidationGroup="V" ControlToValidate="txtTo"
                            ErrorMessage="maskValid"></AjaxControl:MaskedEditValidator>--%>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick="return checkdate()" CssClass="button" ValidationGroup="V"
                            OnClick="btnSubmit_Click" />
                    </td>
                    <td align="left">
                        &nbsp;<asp:Button ID="btnCancel" runat="server" Text="Cancel" CssClass="button" />
                    </td>
                </tr>
            </table>
        </asp:Panel>
        <asp:Panel ID="pnlGrid" runat="server">
            <div style="padding-top: 15px; padding-bottom: 5px; margin-left: 30%;">
                <div style="float: left;">
                    <custom:Pager ID="custPager" runat="server" OnPageChanged="custPager_PageChanged" />
                </div>
                <div style="float: left; margin-left: 10px;">
                    <MyControls:CommonControls ID="CommonControls2" runat="server" GridviewControlId="grdDisplay"
                        HideColumns="8,9" />
                </div>
            </div>
            <div id="divprint" runat="server">
                <asp:GridView ID="grdDisplay" Width="100%" runat="server" AutoGenerateColumns="false"
                    CssClass="gridview" AllowPaging="true" DataKeyNames="tranid,debitnoteid" AlternatingRowStyle-CssClass="gridview_alternate"
                    PagerStyle-CssClass="pgr" OnPageIndexChanging="grdDisplay_OnPageIndexChanging"
                    RowStyle-CssClass="gridviewitem" FooterStyle-CssClass="gridviewitem" OnRowCommand="grdDisplay_RowCommand"
                    OnRowDataBound="grdDisplay_RowDataBound" 
                    OnRowCreated="grdDisplay_RowCreated" 
                    onselectedindexchanged="grdDisplay_SelectedIndexChanged">
                    <Columns>
                        <asp:TemplateField HeaderText="S.No." ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <%# Container.DataItemIndex+1 %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField HeaderText="Debit Note No." DataField="Debitnoteno" />
                        <asp:BoundField HeaderText="Date" DataField="voudate" DataFormatString="{0:dd-MMM-yyyy}" />
                        <asp:BoundField HeaderText="Customer" DataField="customername" />
                        <asp:BoundField HeaderText="Total Amount" DataField="Total" ItemStyle-HorizontalAlign="Right" />
                        <asp:TemplateField HeaderText="Details" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <%--<a href="#">View</a>--%>
                                 <a href="#" onclick="window.open('DebitNoteReport.aspx?debitnoteid=<%#DataBinder.Eval(Container.DataItem,"debitnoteid")%>&tranid=<%#DataBinder.Eval(Container.DataItem,"tranid")%>','','width=800,height=800,toolbar=no,status=yes,menubar=no,scrollbars=yes,resizable=yes')"> View</a>
                            </ItemTemplate>
                        </asp:TemplateField>
                       <asp:CommandField HeaderText="Edit" SelectText="<img src='../../../Menu/images/Edit_user.png' alt='Edit'>"
                                ShowSelectButton="true" />
                    </Columns>
                    <EmptyDataRowStyle ForeColor="Red" Font-Bold="true" HorizontalAlign="Center" />
                    <EmptyDataTemplate>
                        Record Not Found !
                    </EmptyDataTemplate>
                </asp:GridView>
            </div>
        </asp:Panel>
    </div>
    </form>
</body>
</html>

